using System.IO;

namespace ObjFileLoader.Loaders
{
	public abstract class LoaderBase
	{
		private StreamReader _lineStreamReader;

		protected void StartLoad(Stream lineStream)
		{
			_lineStreamReader = new StreamReader(lineStream);
			while (!_lineStreamReader.EndOfStream)
			{
				ParseLine();
			}
		}

		private void ParseLine()
		{
			string text = _lineStreamReader.ReadLine();
			if (!string.IsNullOrWhiteSpace(text) && text[0] != '#')
			{
				string[] array = text.Trim().Split((char[])null, 2);
				string keyword = array[0].Trim();
				string data = array[1].Trim();
				ParseLine(keyword, data);
			}
		}

		protected abstract void ParseLine(string keyword, string data);
	}
}
